home *** CD-ROM | disk | FTP | other *** search
/ CD Actual Thematic 7: Programming / CDAT7.iso / demos / VisualAge for Java 2.0 Entry / setup / data1.cab / ide-e / IDE / cache / TY4QGV (.txt) < prev    next >
Encoding:
Java Class File  |  1998-09-16  |  2.0 KB  |  77 lines

  1. package com.sun.java.swing.border;
  2.  
  3. import java.awt.Component;
  4. import java.awt.Graphics;
  5. import java.awt.Insets;
  6.  
  7. public class CompoundBorder extends AbstractBorder {
  8.    protected Border outsideBorder;
  9.    protected Border insideBorder;
  10.  
  11.    public CompoundBorder() {
  12.       this.outsideBorder = null;
  13.       this.insideBorder = null;
  14.    }
  15.  
  16.    public CompoundBorder(Border outsideBorder, Border insideBorder) {
  17.       this.outsideBorder = outsideBorder;
  18.       this.insideBorder = insideBorder;
  19.    }
  20.  
  21.    public Insets getBorderInsets(Component c) {
  22.       int bottom = 0;
  23.       int right = 0;
  24.       int left = 0;
  25.       int top = 0;
  26.       if (this.outsideBorder != null) {
  27.          Insets nextInsets = this.outsideBorder.getBorderInsets(c);
  28.          top += nextInsets.top;
  29.          left += nextInsets.left;
  30.          right += nextInsets.right;
  31.          bottom += nextInsets.bottom;
  32.       }
  33.  
  34.       if (this.insideBorder != null) {
  35.          Insets var7 = this.insideBorder.getBorderInsets(c);
  36.          top += var7.top;
  37.          left += var7.left;
  38.          right += var7.right;
  39.          bottom += var7.bottom;
  40.       }
  41.  
  42.       return new Insets(top, left, bottom, right);
  43.    }
  44.  
  45.    public Border getInsideBorder() {
  46.       return this.insideBorder;
  47.    }
  48.  
  49.    public Border getOutsideBorder() {
  50.       return this.outsideBorder;
  51.    }
  52.  
  53.    public boolean isBorderOpaque() {
  54.       return this.outsideBorder != null && this.outsideBorder.isBorderOpaque() && this.insideBorder != null && this.insideBorder.isBorderOpaque();
  55.    }
  56.  
  57.    public void paintBorder(Component c, Graphics g, int x, int y, int width, int height) {
  58.       int px = x;
  59.       int py = y;
  60.       int pw = width;
  61.       int ph = height;
  62.       if (this.outsideBorder != null) {
  63.          this.outsideBorder.paintBorder(c, g, x, y, width, height);
  64.          Insets nextInsets = this.outsideBorder.getBorderInsets(c);
  65.          px = x + nextInsets.left;
  66.          py = y + nextInsets.top;
  67.          pw = width - nextInsets.right - nextInsets.left;
  68.          ph = height - nextInsets.bottom - nextInsets.top;
  69.       }
  70.  
  71.       if (this.insideBorder != null) {
  72.          this.insideBorder.paintBorder(c, g, px, py, pw, ph);
  73.       }
  74.  
  75.    }
  76. }
  77.